home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / bash / bash_110 / unixmode / src_d3.zoo / patches.zoo / read.diff < prev    next >
Encoding:
Text File  |  1991-10-30  |  9.0 KB  |  366 lines

  1. diff -c ./readline.c /home/scott/work/st-bash-1.10/lib/readline/readline.c
  2. *** ./readline.c    Thu Oct  3 16:19:58 1991
  3. --- /home/scott/work/st-bash-1.10/lib/readline/readline.c    Sun Oct 27 22:55:24 1991
  4. ***************
  5. *** 30,35 ****
  6. --- 30,44 ----
  7.   static char *xmalloc (), *xrealloc ();
  8.   #endif /* STATIC_MALLOC */
  9.   
  10. + /**
  11. +  ** (sjk)++ On an Atari we need these for the xconsole routines and the 
  12. +  ** definitions of the scan codes for the extended keyboard.
  13. +  **/
  14. + #if defined(atarist)
  15. + #include <osbind.h>
  16. + #include <keycodes.h>
  17. + #endif
  18.   #include <stdio.h>
  19.   #include <sys/types.h>
  20.   #include <fcntl.h>
  21. ***************
  22. *** 48,55 ****
  23.   #  include <unistd.h>
  24.   #endif
  25.   
  26. ! #define NEW_TTY_DRIVER
  27. ! #define HAVE_BSD_SIGNALS
  28.   /* #define USE_XON_XOFF */
  29.   
  30.   /* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */
  31. --- 57,64 ----
  32.   #  include <unistd.h>
  33.   #endif
  34.   
  35. ! #define NEW_TTY_DRIVER 
  36. ! /* #define HAVE_BSD_SIGNALS */
  37.   /* #define USE_XON_XOFF */
  38.   
  39.   /* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */
  40. ***************
  41. *** 85,90 ****
  42. --- 94,107 ----
  43.   #include <sgtty.h>
  44.   #endif
  45.   
  46. + /** 
  47. +  ** (sjk)++ sgtty.h defines META on the Atari ST, so we must undefine it so we 
  48. +  **         get the proper definition of the META macro from readline.h
  49. +  **/
  50. + #if defined(atarist)
  51. + #undef META
  52. + #endif
  53.   #include <errno.h>
  54.   extern int errno;
  55.   
  56. ***************
  57. *** 186,191 ****
  58. --- 203,209 ----
  59.   #define HANDLE_SIGNALS
  60.   
  61.   
  62.   /* **************************************************************** */
  63.   /*                                    */
  64.   /*            Line editing input utility            */
  65. ***************
  66. *** 307,312 ****
  67. --- 325,350 ----
  68.   
  69.   static void rl_prep_terminal (), rl_deprep_terminal ();
  70.   
  71. + /**
  72. +  ** (sjk)++ To get the keyboard mapping right we use the I/O routines 
  73. +  **         from xconsole.c in the termcap library. Here we initialize 
  74. +  **         a few of the more common keys.
  75. +  **/
  76. + #if defined(atarist)
  77. + void initialize_st_bindings()
  78. + {   
  79. +   console_set_key(CURS_UP,"\020"   , (char *)0, (char *)0);
  80. +   console_set_key(CURS_DN,"\016"   , (char *)0, (char *)0);
  81. +   console_set_key(CURS_LF,"\002"   , (char *)0, (char *)0);
  82. +   console_set_key(CURS_RT,"\006"   , (char *)0, (char *)0);
  83. +   console_set_key(K_UNDO, "logout ", "logout
  84. ", (char *)0);
  85. +   console_set_key(K_HELP, "help "  , "help
  86. ", (char *)0);
  87. +   console_set_key(K_INS,  "\t", "echo -en \"\\033E\\\033e
  88. \" ", (char *)0);
  89. +   console_set_key(0x2d,"x","X","\033x");
  90. + }
  91. + #endif
  92.   /* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means
  93.      none.  A return value of NULL means that EOF was encountered. */
  94.   char *
  95. ***************
  96. *** 547,553 ****
  97. --- 585,598 ----
  98.         }
  99.   #else
  100.   #if defined (HAVE_BSD_SIGNALS)
  101. + /**
  102. +  ** (sjk)++ Quitely Ignored on the Atari ST (for now!)
  103. +  **/
  104. + #if !defined(atarist)
  105.         sigsetmask (0);
  106. + #endif
  107.   #endif /* HAVE_BSD_SIGNALS */
  108.   #endif /* HAVE_POSIX_SIGNALS */
  109.   
  110. ***************
  111. *** 703,708 ****
  112. --- 748,758 ----
  113.     long chars_avail;
  114.     char input;
  115.   
  116. + /**
  117. +  ** (sjk)++ For the Atari ST, we use the xconsole routines from termcap 
  118. +  **         to do all the console I/O.                  (thanx Jwahar!)
  119. +  **/
  120. + #if !defined(atarist)
  121.   #if defined (FIONREAD)
  122.     result = ioctl (tty, FIONREAD, &chars_avail);
  123.   #endif
  124. ***************
  125. *** 720,729 ****
  126.         if (chars_avail == -1 && errno == EAGAIN)
  127.       return;
  128.       }
  129.   
  130.     /* If there's nothing available, don't waste time trying to read
  131.        something. */
  132. !   if (chars_avail == 0)
  133.       return;
  134.   
  135.     tem = ibuffer_space ();
  136. --- 770,790 ----
  137.         if (chars_avail == -1 && errno == EAGAIN)
  138.       return;
  139.       }
  140. + #endif 
  141. + #if defined(atarist)
  142. +     if (console_input_status(tty) == 0)          /* tty = fileno(input) */
  143. +       { chars_avail = -1; 
  144. +         return;
  145. +       }
  146. +     else 
  147. +       { chars_avail = 1;
  148. +         input = (char)console_read_byte(tty);     /* tty = fileno(input) */
  149. +       }
  150. + #endif
  151.   
  152.     /* If there's nothing available, don't waste time trying to read
  153.        something. */
  154. !   if (chars_avail < 1)
  155.       return;
  156.   
  157.     tem = ibuffer_space ();
  158. ***************
  159. *** 1062,1067 ****
  160. --- 1123,1135 ----
  161.   {
  162.     extern char *rl_display_prompt;
  163.   
  164. + /** 
  165. +  ** (sjk)++ This is where the Atari ST key bindings are really initialized.
  166. +  **/
  167. + #if defined(atarist)
  168. +    initialize_st_bindings();
  169. + #endif
  170.     /* If we have never been called before, initialize the
  171.        terminal and data structures. */
  172.     if (!rl_initialized)
  173. ***************
  174. *** 1782,1788 ****
  175.         putc (data[i], out_stream);
  176.   #else
  177.         for (i = last_c_pos; i < new; i++)
  178. !     putc (data[i], out_stream);
  179.   #endif                /* HACK_TERMCAP_MOTION */
  180.       }
  181.     else
  182. --- 1850,1856 ----
  183.         putc (data[i], out_stream);
  184.   #else
  185.         for (i = last_c_pos; i < new; i++)
  186. !       putc (data[i], out_stream);
  187.   #endif                /* HACK_TERMCAP_MOTION */
  188.       }
  189.     else
  190. ***************
  191. *** 2156,2162 ****
  192.   
  193.         for (i = 0; i < count; i++)
  194.       putc (' ', out_stream);
  195.         backspace (count);
  196.       }
  197.   }
  198. --- 2224,2229 ----
  199. ***************
  200. *** 2202,2208 ****
  201. --- 2269,2280 ----
  202.     if (terminal_prepped)
  203.       return;
  204.   
  205. + /** 
  206. +  ** (sjk)++ Used to be in a #ifdef HAVE_BSD_SIGNALS (v1.08 and under)
  207. +  **/
  208. + #if !defined(atarist)
  209.     oldmask = sigblock (sigmask (SIGINT));
  210. + #endif 
  211.   
  212.     /* We always get the latest tty values.  Maybe stty changed them. */
  213.     ioctl (tty, TIOCGETP, &the_ttybuff);
  214. ***************
  215. *** 2217,2224 ****
  216.   #if !defined (ANYP)
  217.   #  define ANYP (EVENP | ODDP)
  218.   #endif
  219. !   /* If this terminal doesn't care how the 8th bit is used,
  220.        then we can use it for the meta-key.  We check by seeing
  221.        if BOTH odd and even parity are allowed. */
  222.     if (the_ttybuff.sg_flags & ANYP)
  223. --- 2289,2305 ----
  224.   #if !defined (ANYP)
  225.   #  define ANYP (EVENP | ODDP)
  226.   #endif
  227. !  
  228. !  /**
  229. !   ** (sjk)++ On the Atari ST we set the terminal to (RAW || PASS8) mode 
  230. !   **         to give 8bit Meta Key support.
  231. !   **/
  232. !  #if defined(atarist)
  233. !         the_ttybuff.sg_flags |= (RAW || PASS8);
  234. !  #define LPASS8 PASS8
  235. !  #endif 
  236. !  
  237. !  /* If this terminal doesn't care how the 8th bit is used,
  238.        then we can use it for the meta-key.  We check by seeing
  239.        if BOTH odd and even parity are allowed. */
  240.     if (the_ttybuff.sg_flags & ANYP)
  241. ***************
  242. *** 2287,2293 ****
  243.   #endif /* TIOCGLTC */
  244.   
  245.     the_ttybuff.sg_flags &= ~(ECHO | CRMOD);
  246. !   the_ttybuff.sg_flags |= CBREAK;
  247.     ioctl (tty, TIOCSETN, &the_ttybuff);
  248.   
  249.     terminal_prepped = 1;
  250. --- 2368,2383 ----
  251.   #endif /* TIOCGLTC */
  252.   
  253.     the_ttybuff.sg_flags &= ~(ECHO | CRMOD);
  254. !  /** 
  255. !   ** (sjk)++ Atari ST always should be in RAW mode
  256. !   **/
  257. !  #if !defined(atarist)
  258. !        the_ttybuff.sg_flags |= CBREAK;
  259. !  #else
  260. !        the_ttybuff.sg_flags |= RAW;
  261. !  #endif
  262.     ioctl (tty, TIOCSETN, &the_ttybuff);
  263.   
  264.     terminal_prepped = 1;
  265. ***************
  266. *** 2309,2315 ****
  267. --- 2399,2410 ----
  268.     if (!terminal_prepped)
  269.       return;
  270.   
  271. + /** 
  272. +  ** (sjk)++ Used to be in a #ifdef HAVE_BSD_SIGNALS (v1.08 and under)
  273. +  **/
  274. + #if !defined(atarist)
  275.     oldmask = sigblock (sigmask (SIGINT));
  276. + #endif
  277.   
  278.     the_ttybuff.sg_flags = original_tty_flags;
  279.     ioctl (tty, TIOCSETN, &the_ttybuff);
  280. ***************
  281. *** 3852,3858 ****
  282.                 temp = matches[l];
  283.               else
  284.                 temp++;
  285.               fprintf (out_stream, "%s", temp);
  286.               for (k = 0; k < max - strlen (temp); k++)
  287.                 putc (' ', out_stream);
  288. --- 3947,3952 ----
  289. ***************
  290. *** 5060,5065 ****
  291. --- 5154,5167 ----
  292.       {
  293.         char *temp;
  294.   
  295. + /**
  296. +  ** (sjk)++ We need to alway close, then reopen the directory just
  297. +  **         incase some external command wrote a Auto Symbolic link
  298. +  **         that invalidates the symdir cache.
  299. +  **/
  300. + #if defined(atarist)
  301. +       _del_symdir_cache();
  302. + #endif
  303.         if (dirname) free (dirname);
  304.         if (filename) free (filename);
  305.         if (users_dirname) free (users_dirname);
  306. ***************
  307. *** 5097,5103 ****
  308.   
  309.         rl_filename_completion_desired = 1;
  310.       }
  311.     /* At this point we should entertain the possibility of hacking wildcarded
  312.        filenames, like /usr/man/man<WILD>/te<TAB>.  If the directory name
  313.        contains globbing characters, then build an array of directories to
  314. --- 5199,5205 ----
  315.   
  316.         rl_filename_completion_desired = 1;
  317.       }
  318. !  
  319.     /* At this point we should entertain the possibility of hacking wildcarded
  320.        filenames, like /usr/man/man<WILD>/te<TAB>.  If the directory name
  321.        contains globbing characters, then build an array of directories to
  322. ***************
  323. *** 6230,6236 ****
  324.   {
  325.     int result;
  326.     unsigned char c;
  327.     while (1)
  328.       {
  329.         result = read (fileno (stream), &c, sizeof (char));
  330. --- 6332,6342 ----
  331.   {
  332.     int result;
  333.     unsigned char c;
  334. ! /**
  335. !  ** (sjk)++ We again use the termcap xconsole routines to do input 
  336. !  **         from the console.
  337. !  **/
  338. ! #if !defined(atarist)
  339.     while (1)
  340.       {
  341.         result = read (fileno (stream), &c, sizeof (char));
  342. ***************
  343. *** 6249,6254 ****
  344. --- 6355,6363 ----
  345.         if (errno != EINTR)
  346.       return (EOF);
  347.       }
  348. + #else 
  349. +    c = 0xff & console_read_byte(fileno(stream));
  350. + #endif 
  351.   }
  352.   
  353.   #if defined (STATIC_MALLOC)
  354.